package com.flashcash.kotlin.activity

import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide
import com.flashcash.solu.R
import com.flashcash.solu.app.base.BaseActivity
import com.flashcash.solu.app.base.presenter.BaseActivityPresenter
import com.flashcash.solu.app.base.presenter.BaseActivityPresenterImpl
import com.flashcash.solu.view.MsgBoxActivity
import com.flashcash.kotlin.data.ActivityInfoBean
import org.jetbrains.anko.find
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * @作者:XLEO
 * @创建日期: 2017/8/16 15:03
 * @描述: 活动详情
 *
 * @更新者:${Author}$
 * @更新时间:${Date}$
 * @更新描述:${TODO}
 * @下一步：
 */
@Route(path = "/activity/activity_detail")
class ActivityDetailAcivity : BaseActivity<ActivityDetailPresenter>(), ActivityDetailView {
    @Autowired
    @JvmField
    var data: ActivityInfoBean? = null

    override fun getLayoutResId(): Int {
        return R.layout.activity_activity_detail
    }

    override fun init() {
        initHeader()
        val url = data!!.detailUrl;
        if (!TextUtils.isEmpty(url)) {
            Glide.with(context).load(url).into(find<ImageView>(R.id.iv_activity_detail))
        }
    }

    private fun initHeader() {
        find<ImageButton>(R.id.id_imagebutton_back).onClick {
            finish()
        }
        find<ImageButton>(R.id.id_imagebutton_info_list).onClick {
            startActivity(Intent(applicationContext, MsgBoxActivity::class.java))
        }
        find<TextView>(R.id.id_textview_title).text = getString(R.string.title_activity_detail)
    }

    override fun initPresenterImpl(): ActivityDetailPresenter {
        return ActivityDetailPresenterImpl()
    }

    companion object {
        fun actionStart(context: Context?, activityInfoBean: ActivityInfoBean?) {
            if (activityInfoBean != null) {
                ARouter.getInstance()
                        .build("/activity/activity_detail")
                        .withObject("data", activityInfoBean)
                        .navigation(context)
            }
        }
    }
}

class ActivityDetailPresenterImpl : ActivityDetailPresenter, BaseActivityPresenterImpl() {


}

interface ActivityDetailView {

}

interface ActivityDetailPresenter : BaseActivityPresenter {

}
